package com.tao.com.xiaowen.config.download;

import android.content.Context;
import android.graphics.Bitmap;
import android.os.Handler;
import android.os.Message;

import com.tao.com.xiaowen.model.Model;

import java.io.File;

/**
 * Created by tao on 17-2-26.
 */

public class DownLoadUntils {

    public static void onDownLoadImage(Context context, String url, final Handler handler) {
        DownLoadImageHelper service = new DownLoadImageHelper(context, url, new DownLoadImageHelper.ImageDownLoadCallBack() {
            @Override
            public void onDownLoadSuccess(File file) {

            }

            @Override
            public void onDownLoadSuccess(Bitmap bitmap) {
                handler.obtainMessage();
                Message message = new Message();
                message.what = Model.DOWNLOAD_SUCCESS;
                handler.sendMessage(message);
            }

            @Override
            public void onDownLoadFailed() {
                handler.obtainMessage();
                Message message = new Message();
                message.what = Model.DOWNLOAD_FAILED;
                handler.sendMessage(message);
            }
        });
        new Thread(service).start();
    }
}
